﻿--[[
--@desc: lol游戏状态管理， 好友列表显示游戏状态文字从这里获取
-- 对外提供服务：i_servie_lol_game_status_get_status_str  获取游戏直播显示的字符串
-- 对外广播： i_service_lol_game_status_changed 定时广播游戏直播状态
]]

--[[
event_type:
 //<macro name="BEP_EVENT_MATCHING"            value="1"     desc="正在组队"/>
        //<macro name="BEP_EVENT_ENTER_ROOM"          value="2"     desc="组队成功，进入房间"/>
        //<macro name="BEP_EVENT_SELECTED_CHAMPION"   value="3"     desc="完成选择英雄"/>
        //<macro name="BEP_EVENT_GAME_START"          value="4"     desc="游戏开始"/>
        //<macro name="BEP_EVENT_GAME_END"            value="5"     desc="游戏结束"/> 
        //<macro name="BEP_EVENT_FIRST_BLOOD"         value="6"     desc="一血"/> 
        //<macro name="BEP_EVENT_TRIPLE_KILL"         value="7"     desc="三杀"/> 
        //<macro name="BEP_EVENT_QUADRA_KILL"         value="8"     desc="四杀"/> 
        //<macro name="BEP_EVENT_PENTA_KILL"          value="9"     desc="五杀"/>
        //<macro name="BEP_EVENT_GOD_LIKE"            value="10"    desc=" "/>
        //<macro name="BEP_EVENT_TURRET_KILL"         value="11"    desc="推塔"/>
        //<macro name="BEP_EVENT_BARRACK_KILL"        value="12"    desc="摧毁水晶"/>
        //<macro name="BEP_EVENT_DRAGON_KILL"         value="13"    desc="小龙击杀"/>
        //<macro name="BEP_EVENT_BARON_KILL"          value="14"    desc="大龙击杀"/>
        //<macro name="BEP_EVENT_ACE"                 value="15"    desc="团灭"/>
        //<macro name="BEP_EVENT_ACE"                 value="16"    desc="loading"/>
        //<macro name="BEP_EVENT_TIME_TICK"           value="1000"  desc="定时事件"/>

4. 好友匹配赛正式开始后，显示wording“LOL匹配赛进行中”      <macro name="TLB_BATTLE_TYPE_CLASSIC" value="1" desc="经典模式" />
5. 好友排位赛正式开始后，显示wording“LOL排位赛进行中”  <macro name="TLB_BATTLE_TYPE_5V5_ONE" value="4" desc="5V5单人" />
6. 好友大乱斗正式开始后，显示wording“LOL大乱斗中”     <macro name="TLB_BATTLE_TYPE_ARAM" value="6" desc="大乱斗" />
7. 好友人机对战正式开始后，显示wording“LOL人机对战中”    <macro name="TLB_BATTLE_TYPE_COMPUTER" value="2" desc="人机模式" />
8. 好友自定义模式正式开始后，显示wording“LOL自定义游戏中” <macro name="TLB_BATTLE_TYPE_CUSTOM" value="8" desc="自定义" />

1. 好友成功启动游戏、进入游戏大厅及选择游戏模式、等待匹配、创建房间、游戏结束后的结算页面等均判断为大厅在线，显示wording为“LOL大厅中”
2. 好友选择英雄过程中，显示wording“选择英雄”
3. 好友比赛双方英雄已选择完成，在游戏loading过程中，显示wording“等待开始”
4. 好友匹配赛正式开始后，显示wording“LOL匹配赛进行中”
5. 好友排位赛正式开始后，显示wording“LOL排位赛进行中”
6. 好友大乱斗正式开始后，显示wording“LOL大乱斗中”
7. 好友人机对战正式开始后，显示wording“LOL人机对战中”
8. 好友自定义模式正式开始后，显示wording“LOL自定义游戏中”
9. 好友大乱斗正式开始后，显示wording“LOL大乱斗中”
10. 好友的游戏状态右侧会显示比赛进行时间，并保持跳动更新，若游戏已结束，且未进入游戏结算页面，则时间停止计算，并在时间后面显示“游戏结束”
]]
--[[
    get_friend_game_state data :  {"tgp":"31930002","type":"lol","d":[14,26,1951987721,6,1467890480,75,1,3,0,1,0,0,1,0,0,0,5,0,0]}
    "d":[area_id, 26, game_id, event.event_type, event_time,
            reporter_champion_id,reporter_level,reporter_minions_killed,
            reporter_kill_num,reporter_death_num,reporter_assist_num,
            reporter_team_kill,other_team_kill,reporter_team_turret,other_team_turret,
            reporter_team_dragon,other_team_dragon,reporter_team_baron,other_team_baron,
            game_playing_time, game_mode,
        ]
        status_tbl = {
            event_type = tostring(num_event),
            game_playing_time = param.d[20],
            game_mode = tostring(param.d[21]),
            event_time = param.d[5],
            counter = 0,  -- 计时器
            max_counter = 150;
        }
         

]]
LOL_GAMING_STATUS = {
    --BEP_EVENT_MATCHING            = "1";     --desc="正在组队"/>
    --BEP_EVENT_ENTER_ROOM          = "2";    -- desc="组队成功，进入房间"/>
    BEP_EVENT_SELECTED_CHAMPION   = "3";    -- desc="选择英雄"/>
    BEP_EVENT_GAME_START          = "4";     --desc="游戏开始"/>
    BEP_EVENT_GAME_END            = "5";    -- desc="游戏结束"> 
    BEP_EVENT_GAME_LOADING        = "16";    -- desc="loading"> 
};

LOL_GAME_MODE = {
    TLB_BATTLE_TYPE_CLASSIC             = "1"; --匹配赛
    TLB_BATTLE_TYPE_COMPUTER             = "2"; --LOL人机对战中
    TLB_BATTLE_TYPE_5V5_ONE             = "4"; --排位赛
    TLB_BATTLE_TYPE_ARAM                = "6"; --大乱斗
    TLB_BATTLE_TYPE_CUSTOM             = "8"; --自定义游戏中
};

lol_game_status_mgr = {

    lol_gaming_friend_id_list_ = {};    --正在lol游戏的好友列表
    firend_to_game_status_ = {};

    status_type_to_string = {};
    lol_gaming_user_id_list_ = {};    -- 当前正在玩lol的讨论组用户列表
    lol_gaming_user_last_status_strs = {};

    is_timer_start = false;
    is_friend_loaded = false;
}

function lol_game_status_mgr:init()
    base_utility.log("[lol_game_status_mgr] init");
    comm_center.listen_broadcast("i_broadcast_social_update_game_status", "lol_game_status_mgr:on_broadcast_social_update_game_status");
end

function lol_game_status_mgr:get_lol_gaming_status_string(data)
    local friend_id = data.friend_id;
    local status = self.firend_to_game_status_[friend_id];
    if status == nil then
        base_utility.log("[lol_game_status_mgr] get_lol_gaming_status_string, status == nil.");
        return {status_str = LoadStr("SOCIAL_LOL_GAME_STATUS_LOL_CENTER")};
    end
    local status_str = LoadStr("SOCIAL_LOL_GAME_STATUS_LOL_CENTER");
    local is_valid = lol_game_status_mgr:check_lol_game_status_valid(friend_id);
    if not is_valid then        -- 如果或者无效了，直接返回大厅中
        return {status_str = status_str};
    end
    if status.event_type == LOL_GAMING_STATUS.BEP_EVENT_SELECTED_CHAMPION then
        status_str = LoadStr("SOCIAL_LOL_GAME_STATUS_LOL_CHOICE");
    elseif status.event_type == LOL_GAMING_STATUS.BEP_EVENT_GAME_LOADING then
        status_str = LoadStr("SOCIAL_LOL_GAME_STATUS_LOL_WAITE");
    elseif status.event_type == LOL_GAMING_STATUS.BEP_EVENT_GAME_START then
        --
        if status.game_mode ~= nil and status.game_playing_time ~= nil then
            local time_str = "";
            if status.game_playing_time / 60 >= 100 then
                time_str = string.format("%03d:%02d", math.floor(status.game_playing_time / 60), status.game_playing_time % 60);
            else
                time_str = string.format("%02d:%02d", math.floor(status.game_playing_time / 60), status.game_playing_time % 60);
            end

            if status.game_mode == LOL_GAME_MODE.TLB_BATTLE_TYPE_CLASSIC then
                status_str = string.format(LoadStr("SOCIAL_LOL_GAME_STATUS_LOL_MATCH").."(%s)", time_str);

            elseif status.game_mode == LOL_GAME_MODE.TLB_BATTLE_TYPE_COMPUTER then
                status_str = string.format(LoadStr("SOCIAL_LOL_GAME_STATUS_LOL_MAN_AND_COMPUTER").."(%s)", time_str);

            elseif status.game_mode == LOL_GAME_MODE.TLB_BATTLE_TYPE_5V5_ONE then
                status_str = string.format(LoadStr("SOCIAL_LOL_GAME_STATUS_LOL_GAME").."(%s)", time_str);

            elseif status.game_mode == LOL_GAME_MODE.TLB_BATTLE_TYPE_ARAM then
                status_str = string.format(LoadStr("SOCIAL_LOL_GAME_STATUS_LOL_RANDOM").."(%s)", time_str);

            elseif status.game_mode == LOL_GAME_MODE.TLB_BATTLE_TYPE_CUSTOM then
                status_str = string.format(LoadStr("SOCIAL_LOL_GAME_STATUS_LOL_CUSTOM").."(%s)", time_str);
            end
        end
    end
    return {status_str = status_str};
end

-- 查询是否直播状态: 匹配、排位赛
function lol_game_status_mgr:is_in_live_status(data_in)
    local ret = {is_live = false};
    local is_valid = lol_game_status_mgr:check_lol_game_status_valid(data_in.friend_id);
    if not is_valid then        -- 如果或者无效了，直接返回大厅中
        return ret;
    end

    local status =  self:get_status(data_in.friend_id);
    if status ~= nil and status.event_type ~= LOL_GAMING_STATUS.BEP_EVENT_GAME_END and status.game_mode ~= nil then
        if status.game_mode == LOL_GAME_MODE.TLB_BATTLE_TYPE_5V5_ONE or
            status.game_mode == LOL_GAME_MODE.TLB_BATTLE_TYPE_CLASSIC then
            ret["is_live"] = true;
        end
    end

    return ret;
end

function lol_game_status_mgr:get_status(friend_id)
    return self.firend_to_game_status_[friend_id];
end

function lol_game_status_mgr:update_status(friend_id, new_status)
    self.firend_to_game_status_[friend_id] = new_status;
end

function lol_game_status_mgr:is_firend_in_list(friend_id)
    for i, id in ipairs(self.lol_gaming_friend_id_list_) do
        if id == friend_id then
            return true;
        end
    end
    return false;
end

function lol_game_status_mgr:start_timer()
    local tpfui =
        base_utility.get_component_adapter("ITpf_ui",
            "ierd_tgp.tpf_ui.GetTPFUI();");
    tpfui:AddInterval('lol_game_status_mgr:on_timer', 1000);
    tpfui:AddInterval('lol_game_status_mgr:on_timer_update_couter', 10 * 1000);
    self.is_timer_start = true;
end

function lol_game_status_mgr:stop_timer()
    local tpfui =
        base_utility.get_component_adapter("ITpf_ui",
            "ierd_tgp.tpf_ui.GetTPFUI();");
    tpfui:RemoveInterval('lol_game_status_mgr:on_timer');
    tpfui:RemoveInterval('lol_game_status_mgr:on_timer_update_couter');
    self.is_timer_start = false;
end

function lol_game_status_mgr:on_timer(time_stamp)
    if #self.lol_gaming_friend_id_list_ == 0 and 0 == #self.lol_gaming_user_id_list_ then
        return;
    end

    -- 更新状态:在玩游戏的需要更新
    for id, status in pairs(self.firend_to_game_status_) do
        if status.event_type ~= nil and 
            status.event_type == LOL_GAMING_STATUS.BEP_EVENT_GAME_START and
            status.game_playing_time ~= nil then

            self.firend_to_game_status_[id].game_playing_time = self.firend_to_game_status_[id].game_playing_time + 1;
        end
    end

    if self:is_lol_gaming_friends_status_changed() then
        -- 更新游戏状态:游戏时跑秒
        comm_center.send_broadcast("i_service_lol_game_status_changed", self.lol_gaming_friend_id_list_);
    end
    if #self.lol_gaming_user_id_list_ > 0 then
        comm_center.send_broadcast("i_service_query_lol_game_status_changed", self.lol_gaming_user_id_list_);
    end
end

--游戏好友人数发生变化时，通知C++
function lol_game_status_mgr:set_friendlist_to_social_info_center()
    -- local data = {};
    -- data['friend_list'] = self.lol_gaming_friend_id_list_;
    -- comm_center.call_service("i_service_social_info_center_set_lol_gaming_friend_list", data);
end

function lol_game_status_mgr:insert_friend(friend_id)
    base_utility.log("[lol_game_status_mgr:insert_friend] insert a friend:"..friend_id, true);
    if self.lol_gaming_friend_id_list_[friend_id] == nil then
        table.insert(self.lol_gaming_friend_id_list_, friend_id);
    end

    -- 初始化状态
    if self.firend_to_game_status_[friend_id] ~= nil then
        self.firend_to_game_status_[friend_id] = nil;
    end

    if self.is_timer_start == false then
        self:start_timer();
    end
end

function lol_game_status_mgr:remove_friend(friend_id)

    local is_find = false;
    for i, id in ipairs(self.lol_gaming_friend_id_list_) do
        if id == friend_id then
            table.remove(self.lol_gaming_friend_id_list_, i);
            is_find = true;
            base_utility.log("[lol_game_status_mgr:remove_friend] remove a friend:"..friend_id, true);
            break;
        end
    end

    if is_find == false then
        return;
    end

    if self.firend_to_game_status_[friend_id] ~= nil then
        self.firend_to_game_status_[friend_id] = nil;
    end

    if #self.lol_gaming_friend_id_list_ == 0 and 0 == #self.lol_gaming_user_id_list_ then
        self:stop_timer();
    end
end

function lol_game_status_mgr:update_game_state(event_id, json_str)
    if self.is_friend_loaded == false then
        return;
    end

    local param = base_utility.json_to_table(json_str);
    if param.game_id == GAME_ID.GAME_ID_LOL then

        local gl_adapter =
            base_utility.get_component_adapter("IGame_library",
                "ierd_tgp.game_library.Get_game_library_adapter();");
        local gl_state = ierd_tgp.game_library.GameState:new_local();
        gl_adapter:get_game_state(param.game_id, gl_state);
    
        -- 游戏运行中
        if gl_state.iState == ierd_tgp.game_library.GAME_STATE_RUNNING then
            self:insert_friend(login_model.im_login_infomation.friend_id);
        else            
            self:remove_friend(login_model.im_login_infomation.friend_id);
        end
    end
end

function lol_game_status_mgr:update_lol_game_status_response(tbl_id_list)
    base_utility.log("[lol_game_status_mgr] update_lol_game_status_response" .. base_utility.table_to_json(tbl_id_list));
    if tbl_id_list["update_status_list"] ~= nil and #tbl_id_list["update_status_list"] > 0 then
        for i, user_id in ipairs(tbl_id_list["update_status_list"]) do
            local param_tbl = {
                tgp_id = user_id
            };
            local ret_tbl = comm_center.call_service("i_service_social_info_center_get_lol_player_status", param_tbl);
            if ret_tbl ~= nil and ret_tbl.detail_info ~= nil then
                lol_game_status_mgr:parse_lol_player_status(ret_tbl.detail_info);
            end
        end
    end
end

function lol_game_status_mgr:parse_lol_player_status(detail_json_data)
    local param = base_utility.json_to_table(detail_json_data);
    if param ~= nil and param.tgp ~= nil and param.d ~= nil and "table" == type(param.d) then
        local tgp_id = param.tgp;
        local num_event = lol_game_status_mgr:modify_event_type(param.d[4]);
        local new_status_tbl = {
            event_type = tostring(num_event),
            event_time = param.d[5],
            game_playing_time = param.d[20],
            game_mode = tostring(param.d[21]),
        };

        local old_status_tbl = self:get_status(tgp_id);
        if (old_status_tbl == nil) or (old_status_tbl.game_mode ~= new_status_tbl.game_mode) or 
            (old_status_tbl.event_type ~= new_status_tbl.event_type) or 
            (old_status_tbl.event_time ~= new_status_tbl.event_time) then
            -- 修改最大等待时间和清除counter
            new_status_tbl.max_counter = lol_game_status_mgr:get_max_counter_time(
                new_status_tbl.game_mode, new_status_tbl.event_type);
            new_status_tbl.counter = 0;
        else
            -- 使用原来的值
            new_status_tbl.max_counter = old_status_tbl.max_counter;
            new_status_tbl.counter = old_status_tbl.counter;
        end

        --如果已经在游戏中，时间不再更新，避免时间跳动
        if old_status_tbl ~= nil and 
            old_status_tbl.event_type ~= nil and 
            old_status_tbl.event_type == LOL_GAMING_STATUS.BEP_EVENT_GAME_START and 
            new_status_tbl ~= nil and 
            new_status_tbl.event_type ~= nil and 
            new_status_tbl.event_type == LOL_GAMING_STATUS.BEP_EVENT_GAME_START then
                new_status_tbl.game_playing_time = old_status_tbl.game_playing_time;
        end
        self:update_status(tgp_id, new_status_tbl);           
    else
        base_utility.log("[lol_game_status_mgr] lol game status error:"..base_utility.table_to_json(data), true);
    end
end

-- 登录后拉取好友信息成功
function lol_game_status_mgr:on_get_friendlist_done(event_id, json_str)
    -- 首次登录拉取到好友列表后，查看是否有在游戏中的好友
    self.lol_gaming_friend_id_list_ = {};
    self.is_friend_loaded = true;

    local friend_table = base_utility.json_to_table(json_str)
    if friend_table.friends and #friend_table.friends > 0 then
        for i, friend in ipairs(friend_table.friends) do
            local playing_game_str = friend.playing_game;
            -- 好友列表必将多时，这里
            if string.find(playing_game_str, "\"id\":26") ~= nil then
                self:insert_friend(friend.friend_id);
            end
        end
        self:set_friendlist_to_social_info_center();
    end
end

-- 收到friend_report 检查是否有好友游戏状态改变
function lol_game_status_mgr:recv_friend_report(event_id, json_str)
    local param = base_utility.json_to_table(json_str);
    if param.nType == 0xFF then
        local status_param = base_utility.json_to_table(param["szRemark"]);
        if status_param.type == "status_change" then
            if status_param.status ~= nil and status_param.tgp_id ~= nil then
                
                if status_param.status == "1" then  --1. 上线
                    if status_param.gameid == tostring(GAME_ID.GAME_ID_LOL) then
                        self:insert_friend(status_param.tgp_id);
                    else
                        self:remove_friend(status_param.tgp_id); --只管理LOL
                    end
                elseif status_param.status == "-1" then --2. 离线
                    self:remove_friend(status_param.tgp_id);
                else
                    -- do nothing
                end                
            end
        end
    end
end

-- 拉取是否显示LOL的信息
function lol_game_status_mgr:on_broadcast_social_update_game_status(param)
    local status, game_id = friend_list_model.get_friend_status(param.friend_id);
    if status == friend_list_model.TGP_GAMEING_STATUS and game_id == GAME_ID.GAME_ID_LOL then
        base_utility.log("[lol_game_status_mgr] add_friend_into_friend_list: "..tostring(param.friend_id));
        if self:is_firend_in_list(param.friend_id) == false then
            self:insert_friend(param.friend_id);
            self:set_friendlist_to_social_info_center();
        end
    end
end

-- 好友变化:增加好友
function lol_game_status_mgr:add_friend_into_friend_list(event_id, json_str)
    local param = base_utility.json_to_table(json_str);
    local status, game_id = friend_list_model.get_friend_status(param.friend_id);
    if status == friend_list_model.TGP_GAMEING_STATUS and game_id == GAME_ID.GAME_ID_LOL then
        base_utility.log("[lol_game_status_mgr] add_friend_into_friend_list: "..tostring(param.friend_id));
        self:insert_friend(param.friend_id);
        self:set_friendlist_to_social_info_center();
    end
end

-- 好友变化:删除好友
function lol_game_status_mgr:remove_friend_into_friend_list(event_id, json_str)
    local param = base_utility.json_to_table(json_str);
    self:remove_friend(param.friend_id);
end

-- 接收lol好友的广播
function lol_game_status_mgr:on_lol_player_status_changed(tbl_data)
    if tbl_data ~= nil and tbl_data.detail_info ~= nil then
        lol_game_status_mgr:parse_lol_player_status(tbl_data.detail_info);
    end
end

function lol_game_status_mgr:set_lol_gaming_user_list(event_id, json_str)
    local user_list_param = base_utility.json_to_table(json_str);
    if user_list_param ~= nil and user_list_param.user_list ~= nil then
        self.lol_gaming_user_id_list_ = {};
        self.lol_gaming_user_id_list_ = user_list_param.user_list;
    end

    if #self.lol_gaming_friend_id_list_ == 0 and 0 == #self.lol_gaming_user_id_list_ then
        self:stop_timer();
    else
        if self.is_timer_start == false then
            self:start_timer();
        end
    end
end

function lol_game_status_mgr:modify_event_type(event_type)
    if event_type ~= nil then
        local num_event = tonumber(event_type);
        if (num_event > 5 and num_event < 16) or (num_event == 1000) then
            num_event = 4;
        end
        return num_event;
    end
    return 0;
end
-- 获取特定模式下的最大等待时间
function lol_game_status_mgr:get_max_counter_time(game_mode, event_type)
    local max_counter = 0;
    if LOL_GAME_MODE.TLB_BATTLE_TYPE_CLASSIC == game_mode then   -- 匹配赛
        if LOL_GAMING_STATUS.BEP_EVENT_SELECTED_CHAMPION == event_type then
            max_counter = 150;
        elseif LOL_GAMING_STATUS.BEP_EVENT_GAME_LOADING == event_type then
            max_counter = 600;
        elseif LOL_GAMING_STATUS.BEP_EVENT_GAME_START == event_type then
            max_counter = 90 * 60;
        end
    elseif LOL_GAME_MODE.TLB_BATTLE_TYPE_5V5_ONE == game_mode then  -- 排位赛
        if LOL_GAMING_STATUS.BEP_EVENT_SELECTED_CHAMPION == event_type then
            max_counter = 600;
        elseif LOL_GAMING_STATUS.BEP_EVENT_GAME_LOADING == event_type then
            max_counter = 600;
        elseif LOL_GAMING_STATUS.BEP_EVENT_GAME_START == event_type then
            max_counter = 90 * 60;
        end
    else
        if LOL_GAMING_STATUS.BEP_EVENT_SELECTED_CHAMPION == event_type then
            max_counter = 150;
        elseif LOL_GAMING_STATUS.BEP_EVENT_GAME_LOADING == event_type then
            max_counter = 600;
        elseif LOL_GAMING_STATUS.BEP_EVENT_GAME_START == event_type then
            max_counter = 90 * 60;
        end
    end
    return max_counter;
end

function lol_game_status_mgr:check_lol_game_status_valid(tgp_id)
    local is_valid = true;
    local status_tbl = self.firend_to_game_status_[tgp_id];
    if nil == status_tbl then return is_valid end

    if LOL_GAMING_STATUS.BEP_EVENT_SELECTED_CHAMPION == status_tbl.event_type or
        LOL_GAMING_STATUS.BEP_EVENT_GAME_LOADING == status_tbl.event_type or
        LOL_GAMING_STATUS.BEP_EVENT_GAME_START == status_tbl.event_type then
        if status_tbl.counter >= status_tbl.max_counter then
            is_valid = false;
        end
    end
    return is_valid;
end

function lol_game_status_mgr:on_timer_update_couter()
    for tgp_id, status_tbl in pairs(self.firend_to_game_status_) do
        if status_tbl ~= nil then
            status_tbl.counter = status_tbl.counter + 10;
            local is_valid = lol_game_status_mgr:check_lol_game_status_valid(tgp_id);
            if not is_valid then
              -- 抛出异常事件
                local param_tbl = {
                    tgp_id = tgp_id;
                };
                event_center.send_event(social_event.LOL_GAME_USER_STATUS_EXCEPTION, 
                    base_utility.table_to_json(param_tbl));
            end
        end
    end
end

function lol_game_status_mgr:check_lol_status_valid_service(param_tbl)
    local ret_tbl = {
        is_valid = 1;
    };
    if nil == param_tbl or nil == param_tbl.tgp_id then
        return ret_tbl;
    end
    if lol_game_status_mgr:check_lol_game_status_valid(param_tbl.tgp_id) then
        ret_tbl.is_valid = 1;
    else
        ret_tbl.is_valid = 0;
    end  
    return ret_tbl;
end

function lol_game_status_mgr:is_playing_lol_game(param_tbl)
    local ret_tbl = {
        is_playing_lol = 0;
    };
    if nil == param_tbl or nil == param_tbl.tgp_id then
        return ret_tbl;
    end
    if lol_game_status_mgr:is_firend_in_list(param_tbl.tgp_id) then
        ret_tbl.is_playing_lol = 1;
    else 
        ret_tbl.is_playing_lol = 0;
    end
    return ret_tbl;
end

function lol_game_status_mgr:get_lol_gaming_friend_list(param_tbl)
    local ret_tbl = {
        lol_friend_list = self.lol_gaming_friend_id_list_;
    };
    return ret_tbl;
end

function lol_game_status_mgr:is_lol_gaming_friends_status_changed()
    local status_changed = false;
    for index = 1, #self.lol_gaming_friend_id_list_ do
        local lol_friend_id = self.lol_gaming_friend_id_list_[index];
        local param = { friend_id = lol_friend_id };
        local status = self:get_lol_gaming_status_string(param);
        if status.status_str ~= self.lol_gaming_user_last_status_strs[lol_friend_id] then
            self.lol_gaming_user_last_status_strs[lol_friend_id] = status.status_str;
            status_changed = true;
        end
    end
    return status_changed;
end

lol_game_status_mgr:init();
